package com.inspectionwork.web.web;

import cn.hutool.json.JSONObject;
import com.inspectionwork.common.base.BaseController;
import com.inspectionwork.support.annotaion.Action;
import com.inspectionwork.support.annotaion.At;
import com.inspectionwork.support.model.RespEntity;
import com.inspectionwork.web.service.SafetyKnowledgeService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;

/**
 * @Author: YangYu
 * @ClassName: SafetyKnowledgeController
 * @Date: Created in 14:18 2022/6/23
 * @Description: 安全知识
 */
@Action
@RequestMapping(value="safetyknowledge")
public class SafetyKnowledgeController extends BaseController {

    @Resource
    private SafetyKnowledgeService safetyKnowledgeService;

    /**
     * @Author YangYu
     * @Description 安全知识分页列表
     * @Date Created in 14:20 2022/6/23
     * @Param [jsonParam]
     */

    @At(value = "getSafetyKnowledgeListPage", method = RequestMethod.GET, param = { "page","limit","knowledgeType"})
    public RespEntity getSafetyKnowledgeListPage(@RequestBody(required = false) JSONObject jsonParam) {
        return safetyKnowledgeService.getSafetyKnowledgeListPage(jsonParam);
    }
    /**
     * @Author YangYu
     * @Description 新增、更新文章
     * @Date Created in 14:20 2022/6/23
     * @Param [jsonParam]
     */

    @At(value = "addOrUpdateArticle", method = RequestMethod.POST)
    public RespEntity addOrUpdateArticle(@RequestBody(required = false) JSONObject jsonParam) {
        return safetyKnowledgeService.addOrUpdateArticle(jsonParam);
    }
    /**
     * @Author YangYu
     * @Description 删除文章
     * @Date Created in 14:20 2022/6/23
     * @Param [jsonParam]
     */

    @At(value = "delArticle", method = RequestMethod.POST)
    public RespEntity delArticle(@RequestBody(required = false) JSONObject jsonParam) {
        return safetyKnowledgeService.delArticle(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 文章操作
     * @Date Created in 14:20 2022/6/23
     * @Param [jsonParam]
     */

    @At(value = "articleOperation", method = RequestMethod.POST)
    public RespEntity articleOperation(@RequestBody(required = false) JSONObject jsonParam) {
        return safetyKnowledgeService.articleOperation(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 安全知识评论分页列表
     * @Date Created in 14:20 2022/6/23
     * @Param [jsonParam]
     */

    @At(value = "getCommentListPage", method = RequestMethod.GET, param = { "page","limit","knowledgeId"})
    public RespEntity getCommentListPage(@RequestBody(required = false) JSONObject jsonParam) {
        return safetyKnowledgeService.getCommentListPage(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 新增评论
     * @Date Created in 14:20 2022/6/23
     * @Param [jsonParam]
     */

    @At(value = "addComment", method = RequestMethod.POST, param = { "knowledgeId","content","userName"})
    public RespEntity addComment(@RequestBody(required = false) JSONObject jsonParam) {
        return safetyKnowledgeService.addComment(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 删除评论
     * @Date Created in 14:20 2022/6/23
     * @Param [jsonParam]
     */

    @At(value = "delComment", method = RequestMethod.POST)
    public RespEntity delComment(@RequestBody(required = false) JSONObject jsonParam) {
        return safetyKnowledgeService.delComment(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 图文类型列表
     * @Date Created in 10:52 2022/7/6
     * @Param [jsonParam]
     */

    @At(value = "textTypeList", method = RequestMethod.GET)
    public RespEntity textTypeList(@RequestBody(required = false) JSONObject jsonParam) {
        return safetyKnowledgeService.textTypeList(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 图文类型详情
     * @Date Created in 10:52 2022/7/6
     * @Param [jsonParam]
     */

    @At(value = "detailsTextType", method = RequestMethod.GET, param = { "id"})
    public RespEntity detailsTextType(@RequestBody(required = false) JSONObject jsonParam) {
        return safetyKnowledgeService.detailsTextType(jsonParam);
    }
    /**
     * @Author YangYu
     * @Description 新增、更新图文类型
     * @Date Created in 14:20 2022/6/23
     * @Param [jsonParam]
     */

    @At(value = "addOrUpdateTextType", method = RequestMethod.POST, param = { "name"})
    public RespEntity addOrUpdateTextType(@RequestBody(required = false) JSONObject jsonParam) {
        return safetyKnowledgeService.addOrUpdateTextType(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 删除图文类型
     * @Date Created in 14:20 2022/6/23
     * @Param [jsonParam]
     */

    @At(value = "delTextType", method = RequestMethod.POST, param = { "id"})
    public RespEntity delTextType(@RequestBody(required = false) JSONObject jsonParam) {
        return safetyKnowledgeService.delTextType(jsonParam);
    }

}
